Developer Documentation

QuickTime 4 API Documentation

QuickTime 4 Reference

| Previous | Chapter Contents | Chapter Top | Next |

General Data Management

This section contains several new functions to support modifier tracks, active segments, and video settings. These functions apply to all derived media handler components.

MediaGSetActiveSegment

The MediaGSetActiveSegment function informs your derived media handlers of the current active segment.

pascal ComponentResult MediaGSetActiveSegment(
                     MediaHandler mh,
                     TimeValue activeStart,
                     TimeValue activeDuration);
mh
Identifies the Movie Toolbox's connection to your derived media handler.

activeStart
Contains the starting time of the active segment to play. This time value is expressed in your movie's time scale.

activeDuration
Contains a time value that specifies the duration of the active segment. This value is expressed in the movie's time scale.

DISCUSSION

Using the SetMovieActiveSegment function, an application can limit the time segment of the movie that will be used for play back. Derived media handlers are given the values for the active segment by the MediaGSetActiveSegment function called by the toolbox. Active segment information is usually only needed by media handlers that perform their own scheduling.

MediaInvalidateRegion

The MediaInvalidateRegion function updates the invalidated display region the next time MediaIdle is called.

pascal ComponentResult MediaInvalidateRegion(
                     MediaHandler mh,
                     RgnHandle invalRgn);
mh
Identifies the Movie Toolbox's connection to your derived media handler.

invalRgn
Contains a handle to a region that has been invalidated. Your media handler should not dispose or modify this region. The invalRgn parameter is never nil .

DISCUSSION

The MediaInvalidateRegion function is called by the toolbox when UpdateMovie or InvalidateMovieRegion is called with a region that intersects your media's track.

Derived media handlers need to implement MediaInvalidateRegion only if they can perform efficient updates on a portion of their display area.

If a media handler implements the MediaInvalidateRegion function, it is responsible for ensuring that the appropriate areas of the screen are updated on the next call to MediaIdle . If a media handler does not implement this function, the base media handler sets the mMustDrawflag the next time MediaIdle is called.

MediaGetNextStepTime

The MediaGetNextStepTime function searches for the next forward or backward step time from the given media time. The step time is the time of the next frame. This function allows a derived media handler to return the next step time from the specified media time.

pascal ComponentResult MediaGetNextStepTime(
                     MediaHandler mh,
                     short flags,
                     TimeValue mediaTimeIn,
                     TimeValue *mediaTimeOut,
                     Fixed rate);
mh
Identifies the Movie Toolbox's connection to your derived media handler.

flags
The following interestingTimeFlags flags are defined:

nextTimeStep
Searches for the next frame in the media. Set this flag to 1 to search for the next frame.

nextTimeEdgeOk
Instructs the toolbox that you are willing to receive information about elements that begin or end at the time specified by the mediaTimeIn parameter. Set this flag to 1 to accept this information. This flag is especially useful at the beginning or end of a media. The function returns valid information about the beginning and end of the media.

mediaTimeIn
Specifies a time value that establishes the starting point for the search. This time value is in the media's time scale.

mediaTimeOut
The step time calculated by the media handler. The media handler should return the first time value it finds that meets the search criteria specified in the flags parameter. This time value is in the media's time scale.

rate
Contains the search direction. Negative values search backward from the starting point specified in the mediaTimeIn parameter. Other values cause a forward search.

DISCUSSION

The mechanism in QuickTime used for stepping backwards and forwards a frame at a time are the interesting time calls: GetMovieNextInterestingTime , GetTrackNextInterestingTime , and GetMediaNextInterestingTime . The normal method for stepping forward to the next frame is to use one of these calls to locate the time of the next visual sample. This works well for most media types, including video and text. Unfortunately, it does not work well for MPEG. QuickTime stores an entire MPEG stream as a single sample. Therefore stepping to the next sample would actually skip to the end of the entire sequence. To solve this problem, QuickTime 2.1 introduced a new flag, nextTimeStep , for the interesting time calls. This flag is specifically intended for stepping through frames.

The standard QuickTime movie controller has been updated to use this flag in place of the old nextTimeSample flag. The nextTimeStep flag works correctly for all media types including video and MPEG. To work correctly with MPEG, applications that implement stepping functionality should use this new flag.

See Inside Macintosh: QuickTime for more information on interesting times.

MediaTrackReferencesChanged

The MediaTrackReferencesChanged function notifies the derived media handler whenever the track references in the movie change.

pascal ComponentResult MediaTrackReferencesChanged (MediaHandler mh);
mh
Identifies the Movie Toolbox's connection to your derived media handler.

DISCUSSION

When an application creates, modifies, or deletes a track reference, the media handler's MediaTrackReferencesChanged function is called. When this function is called, a media handler should rebuild all information about track references and reset its values for all media inputs to their default values.

MediaTrackPropertyAtomChanged

The MediaTrackPropertyAtomChanged function notifies the derived media handler whenever its media property atom has changed.

pascal ComponentResult MediaTrackPropertyAtomChanged (MediaHandler mh);
mh
Identifies the Movie Toolbox's connection to your derived media handler.

DISCUSSION

The MediaTrackPropertyAtomChanged function is called whenever SetMediaPropertyAtom is called. If the media handler uses information from the property atom, it should rebuild the information at this time.

MediaSetTrackInputMapReference

When an application modifies the media input map, the MediaSetTrackInputMap function provides the derived media handler with the updated input map.

pascal ComponentResult MediaSetTrackInputMapReference(
                     MediaHandler mh,
                     QTAtomContainer inputMap);
mh
Identifies the Movie Toolbox's connection to your derived media handler.

inputMap
Specifies the media input map for this operation. Do not modify or dispose of the input map provided.

DISCUSSION

When the MediaSetTrackInputMapReference function is called, the media handler should store the updated input map and recheck the types of all inputs, if it is caching this information. The input map reference passed to this function should not be disposed of or modified by the media handler.

MediaGetSampleDataPointer

The MediaGetSampleDataPointer function allows a derived media handler to obtain a pointer to the sample data for a particular sample number, the size of that sample, and the index of the sample description associated with that sample.

pascal ComponentResult MediaGetSampleDataPointer(
                     MediaHandler mh,
                     long sampleNum,
                     Ptr *dataPtr,
                     long *dataSize,
                     long *sampleDescIndex);
mh
Identifies the Movie Toolbox's connection to your derived media handler.

sampleNum
Contains the number of the sample that is to be loaded.

dataPtr
Contains a pointer to a pointer to receive the address of the loaded sample data.

dataSize
Contains a pointer to a field that is to receive the size, in bytes, of the sample.

sampleDescIndex
Contains a pointer to a long integer. The MediaGetSampleDataPointer function returns an index value to the sample description that corresponds to the returned sample data. If you do not want this information, set this parameter to nil .

DISCUSSION

The MediaGetSampleDataPointer function returns a pointer to the data for a particular sample number from a movie data file.

This function provides access to the base media handler's caching services for sample data. It is a service provided by the base media handler for its clients.

Each call to MediaGetSampleDataPointer must be balanced by a call to MediaReleaseSampleDataPointer or the memory will not be released. MediaGetSampleDataPointer generally provides better overall performance than GetMediaSample .

MediaReleaseSampleDataPointer

The MediaReleaseSampleDataPointer function balances calls to MediaGetSampleDataPointer to release the memory. This function should be used only by derived media handlers.

pascal ComponentResult MediaReleaseSampleDataPointer(
                     MediaHandler mh,
                     long sampleNum);
mh
Identifies the Movie Toolbox's connection to your derived media handler.

sampleNum
Contains the number of the sample that is to be released.

MediaCompare

The MediaCompare function allows a media handler to determine whether the Movie Toolbox should allow one track to be pasted into another. MediaCompare is provided with a reference to the media with which it should be compared.

pascal ComponentResult MediaCompare(
                     MediaHandler mh,
                     Boolean *isOK,
                     Media srcMedia,
                     ComponentInstance srcMediaComponent);
mh
Identifies the toolbox's connection to your derived media handler.

isOK
Contains a pointer to a Boolean value. Your media handler must set this Boolean value to indicate whether the source media and the media associated with the media handler have equivalent media settings, so that pasting the two together would cause no media information loss.

srcMedia
Specifies the source media for this operation.

srcMediaComponent
Specifies the source media component for this operation.

MediaSetVideoParam

The MediaSetVideoParam function enables you to dynamically adjust the brightness, contrast, hue, sharpness, saturation, black level, and white level of a video image.

pascal ComponentResult MediaSetVideoParam(
                     MediaHandler mh,
                     long whichParam,
                     unsigned short *value);
mh
Identifies the Movie Toolbox's connection to your derived media handler.

whichParam
Contains a long integer that specifies the number of the video parameter that should be adjusted.

value
Contains the actual value of the video parameter. The meaning of the values vary depending on the implementation.

DISCUSSION

The MediaSetVideoParam and MediaGetVideoParam functions are currently used by the MPEG media handler.

See "Media Video Parameters" for the constants and values you can use for the whichParam and value parameters.

MediaGetVideoParam

The MediaGetVideoParam function enables you to retrieve the value of the brightness, contrast, hue, sharpness, saturation, black level, or white level of a video image.

pascal ComponentResult MediaGetVideoParam(
                     MediaHandler mh,
                     long whichParam,
                     unsigned short *value);
mh
Identifies the Movie Toolbox's connection to your derived media handler.

whichParam
Contains a long integer thatspecifies the number of the video parameter whose value you want to retrieve.

value
Contains the actual value of the requested video parameter. The meaning of the values vary depending on the implementation.

DISCUSSION

The MediaSetVideoParam and MediaGetVideoParam functions are currently used by the MPEG media handler.

See the Inside Macintosh: QuickTime Components chapter on Video Digitizer Components for more information about the whichParam and value parameters.

MediaSetNonPrimarySourceData

The MediaSetNonPrimarySourceData function allows a media handler to support receiving media data from other media handlers.

pascal ComponentResult MediaSetNonPrimarySourceData(
                     MediaHandler mh,
                     long inputIndex,
                     long dataDescriptionSeed,
                     Handle dataDescription,
                     void *data,
                     long dataSize,
                     ICMCompletionProcRecordPtr asyncCompletionProc,
                     UniversalProcPtr transferProc,
                     void *refCon);
mh
Identifies the Movie Toolbox's connection to your derived media handler.

inputIndex
This value is the ID of the entry in the media's input map to which the data provided by the call corresponds.

dataDescriptionSeed
This value is changed each time the dataDescription has changed. This allows for a quick check by the media handler to see if the dataDescription has changed.

dataDescription
A handle to a data structure describing the input data.

data
Points to the input data. This pointer must contain a 32-bit address.

dataSize
Contains the size of the sample in bytes.

asyncCompletionProc
Points to a completion function structure. If the asyncCompletionProc is set to nil , the data pointer will be valid only for the duration of this call. If the asyncCompletionProc is not nil , it contains an ICMCompletionProcRecord that must be called when your media handler is done with the provided data pointer.

transferProc
A routine that allows the application to transform the type of the input data to the kind of data preferred by the codec. The client of the codec passes the source data in the form most convenient for it. If the codec needs the data in another form, it can negotiate with the caller or directly with the Image Compression Manager to obtain the required data format.

refCon
Contains a reference constant (defined as a void pointer). Your application specifies the value of this reference constant in the function structure you pass to the media handler.

DISCUSSION

There are two tasks required to support modifier tracks in a derived media handler: sending and receiving. The base media handler takes care of sending data for all its clients. Therefore, authors of derived media handlers do not usually need to implement sending data support.

Receiving data is a more complex situation. The base media handler takes care of input types that it understands. The base media handler supports the following types of data:

kTrackModifierTypeMatrix
kTrackModifierTypeGraphicsMode
kTrackModifierTypeClip
kTrackModifierTypeVolume
kTrackModifierTypeBalance

If a media handler wants to support receiving other types of data it must implement the MediaSetNonPrimarySourceData routine. MediaSetNonPrimarySourceData is called by modified tracks to supply the current data for each input. All unrecognized input types should be delegated to the base media handler so that they can be handled.

The following is a basic shell implementation of a derived media handler's MediaSetNonPrimarySourceData function. Note that your derived media handler must delegate all input types it does not handle to the base media handler.

pascal ComponentResult MySetNonPrimarySourceData( MyGlobals store,
    long inputIndex, long dataDescriptionSeed, Handle dataDescription,
    void *data, long dataSize,
    ICMCompletionProcRecordPtr asyncCompletionProc,
    UniversalProcPtr transferProc, void *refCon )
{
ComponentResult err = noErr;
QTAtom inputAtom;
QTAtom typesAtom;
long inputType;

// determine what kind of input this is
inputAtom = QTFindChildByID(store->inputMap,
    kParentAtomIsContainer, kTrackModifierInput, inputIndex, nil);
if (!inputAtom) {
    err = cannotFindAtomErr;
    goto bail;
}
    typesAtom = QTFindChildByID(store->inputMap, inputAtom,
    kTrackModifierType, 1, nil);
err = QTCopyAtomDataToPtr(store->inputMap, typesAtom, false,
    sizeof(inputType), &inputType, nil);
if (err) goto bail;

switch(inputType) {
    case kMyInputType:
        if (data == nil) {
            // no data, reset to default value
        }
        else {
            // use this data
            // when done, notify caller we're done with this data
            if (asyncCompletionProc)
                CallICMCompletionProc(
                    asyncCompletionProc->completionProc,
                    noErr, codecCompletionSource | codecCompletionDest,
                    asyncCompletionProc->completionRefCon);
        }
        break;

    default:
        err = MediaSetNonPrimarySourceData(store->delegateComponent,
            inputIndex, dataDescriptionSeed, dataDescription, data,
            dataSize, asyncCompletionProc, transferProc, refCon);
        break;
}
bail:
    return err;
}

MediaGetOffscreenBufferSize

The MediaGetOffscreenBufferSize function determines the dimensions of the offscreen buffer.

pascal ComponentResult MediaGetOffscreenBufferSize(
                     MediaHandler mh,
                     Rect *bounds,
                     short depth,
                     CTabHandle ctab);
mh
Identifies the Movie Toolbox's connection to your derived media handler.

bounds
Specifies the boundaries of your offscreen buffer.

depth
Specifies the depth of the offscreen.

ctab
Contains a handle to the color table associated with the offscreen buffer.

DISCUSSION

Before the base media handler allocates an offscreen buffer for your derived media handler, it calls your MediaGetOffscreenBufferSize function. The depth and color table used for the buffer are also passed. When this function is called, the bounds parameter specifies the size that the base media handler intends to use for your offscreen buffer. You can modify this as appropriate before returning. This capability is useful if your media handler can draw only at particular sizes. It is also useful for implementing antialiased drawing; you can request a buffer that is larger than your destination area and have the base media handler scale the image down for you.

RESULT CODES

badComponentInstance
0x80008001 Invalid component instance specified

MediaSetHints

The MediaSetHints function implements the appropriate behavior for the various media hints such as scrub mode and high-quality mode.

pascal ComponentResult MediaSetHints(
                     MediaHandler mh,
                     long hints);
mh
Identifies the Movie Toolbox's connection to your derived media handler.

hints
Contains all hint bits that currently apply to the given media.

DISCUSSION

When an application calls SetMoviePlayHints or SetMediaPlayHints , your media handler's MediaSetHints routine is called.

RESULT CODES

badComponentInstance
0x80008001 Invalid component instance specified

MediaGetName

The MediaGetName function returns the name of the media type. For example, the video media handler returns the string 'video' .

pascal ComponentResult MediaGetName(
                     MediaHandler mh,
                     Str255 name,
                     long requestedLanguage,
                     long *actualLanguage);
mh
Identifies the Movie Toolbox's connection to your derived media handler.

name
Specifies where to return the name of the media type.

requestedLanguage
Specifies the language in which you want the name returned. This value is a standard Mac OS region code.

actualLanguage
Specifies the actual language in which the name is returned. This value is a standard Mac OS region code.

function result
The name of the media type.

RESULT CODES

badComponentInstance
0x80008001 Invalid component instance specified

© 1999 Apple Computer, Inc.

| Previous | Chapter Contents | Chapter Top | Next |